package lu.med.praxiswahl.wahlumed.client.forms;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

import lu.med.praxiswahl.wahlumed.client.wclient.Main;

/**
 * 
 * @author Lars Holger Roth
 */
@SuppressWarnings("serial")
public class FormsDialog extends JFrame {
	public FormsDialog(Main dataManager, String matricule, int formType,
			String fileName, final FormsRefreshListener owner, Long id,
			int pages) {
		super("Formular Editor");
		this.setLayout(new BorderLayout());
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		this.setLocation(0, 0);
		this.add(new FormsPanel(dataManager, matricule, formType, fileName,
				owner, id, this, pages), BorderLayout.CENTER);
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		this.setSize((int) screen.getWidth(), (int) screen.getHeight());
		this.repaint();
		this.setVisible(true);

		this.addWindowListener(new WindowListener() {

			@Override
			public void windowOpened(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowIconified(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowDeiconified(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowDeactivated(WindowEvent e) {
				owner.refresh();
			}

			@Override
			public void windowClosing(WindowEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowClosed(WindowEvent e) {

			}

			@Override
			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub

			}
		});
	}

	@Override
	public void setVisible(boolean in) {
		super.setVisible(in);
		this.setExtendedState(Frame.MAXIMIZED_BOTH);
	}
}
